﻿using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Steamrunner
{
    class Camera2D
    {
        #region Properties
        public float Rotation
        {
            get;
            set;
        }

        public Vector2 Origin
        {
            get;
            set;
        }

        public float Scale
        {
            get;
            set;
        }

        public Vector2 Center
        {
            get;
            protected set;
        }

        public Matrix Transform
        {
            get;
            set;
        }

        public Vector2 Position
        {
            get;
            set;
        }
        #endregion

        public Camera2D()
        {
        }

        public void Initialize(Viewport vp)
        {
            Center = new Vector2(vp.Width * 0.5f, vp.Height * 0.5f);
            Scale = 1.0f;
        }

        public void Update()
        {
            Origin = Center / 1.0f;
            Transform = Matrix.Identity *
                Matrix.CreateTranslation(-Position.X, -Position.Y, 0.0f) *
                Matrix.CreateRotationZ(Rotation) *
                Matrix.CreateTranslation(Origin.X, Origin.Y, 0.0f) *
                Matrix.CreateScale(1.0f);
        }
    }
}
